package com.zx.jhpt.job;

/**
 * Created by Administrator on 2016/3/3.
 */

import java.util.List;

import javax.annotation.Resource;

import com.zx.jhpt.datamart.DataMart;
import org.apache.log4j.Logger;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.zx.jhpt.datamart.LogDynamicService;
import com.zx.jhpt.datamart.MarketEngine;
import com.zx.jhpt.service.MarketEngineService;

/**
 * 定时拉取数据
 */
@Component
public class PullDataQuartz {
    private static final Logger LOGGER = Logger.getLogger(PullDataQuartz.class);
    @Resource
    private LogDynamicService logDynamicService;
    @Resource
    private MarketEngineService marketEngineService;
    /**
     * 每天定时拉取数据
     */
//    @Scheduled(cron = "0/30 * * * * ?")
    public void pullData() {
        LOGGER.debug("开始拉取数据...");
        try{
            List<DataMart> lists = MarketEngine.getAll();
            for(DataMart dataMart:lists){
                logDynamicService.synData(dataMart);
            }
        }catch (Exception e){
            LOGGER.error("数据同步出错..."+e.getMessage());
        }

    }
}
